<?php
//判断上传的文件是否出错,是的话，返回错误
if($_FILES["face"]["error"])
{
    echo $_FILES["face"]["error"];
    exit;
}
else
{
    $files = $_FILES["face"];
    //没有出错
    //加限制条件
    //判断上传文件类型为png或jpg且大小不超过1024000B
    if(($_FILES["face"]["type"]=="image/png"||$_FILES["face"]["type"]=="image/jpeg")&&$_FILES["face"]["size"]<1024000)
    {
        //防止文件名重复

        // $path = time().$_FILES["face"]["name"];
        $ext = strtolower(pathinfo($files['name'],PATHINFO_EXTENSION));
        $fileName = md5(uniqid(microtime(true),true)).'.'.$ext;
        $path = "./uploads/shop/";
        $destName = $path.$fileName;
        //检查文件或目录是否存在
        if(file_exists("/uploads/shop/"))
        {
            $info = "该文件已存在";
        }
        else
        {
            if (move_uploaded_file($files['tmp_name'],$destName)){
                $info =  $destName;
            }else{
                $info =  "上传失败";
            }
        }
    }
    else
    {
        $info = "文件类型不对";
    }
	echo ltrim($info,".");exit;
}
?>